import { IPSDEDRBar } from './ipsdedrbar';
import { IPSDEDRBarGroup } from './ipsdedrbar-group';
import { IPSDEDRBarItem } from './ipsdedrbar-item';
import { PSDEDRCtrlItemImpl } from './psdedrctrl-item-impl';

export class PSDEDRBarItemImpl extends PSDEDRCtrlItemImpl implements IPSDEDRBarItem {
  protected psdedrbargroup: IPSDEDRBarGroup | null = null;

  getPSDEDRBarGroup(): IPSDEDRBarGroup | null {
    if (this.psdedrbargroup != null) return this.psdedrbargroup;
    const value = this.M.getPSDEDRBarGroup;
    if (value == null) {
      return null;
    }
    const ipsdedrbar = this.getParentPSModelObject('control.drctrl.IPSDEDRBar') as IPSDEDRBar;
    if (ipsdedrbar != null) {
      this.psdedrbargroup = ipsdedrbar.findPSDEDRBarGroup(value);
    }
    return this.psdedrbargroup;
  }

  get psDEDRBarGroup(): IPSDEDRBarGroup | null {
    return this.getPSDEDRBarGroup();
  }

  getPSDEDRBarGroupMust(): IPSDEDRBarGroup {
    const value = this.getPSDEDRBarGroup();
    if (value == null) {
      throw new Error('未指定关系栏项分组');
    }
    return value;
  }

  get cls(): string {
    return 'PSDEDRBarItemImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.drctrl.IPSDEDRBarItem') return true;
    return super.instanceof(cls);
  }
}
